package com.jzqf.android.alive

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.util.Log

class ScreenReceiver : BroadcastReceiver() {
    override fun onReceive(context: Context, intent: Intent) {
        Log.d("保活 ScreenReceiver", "收到广播: ${intent.action}")
        if (intent.action == Intent.ACTION_USER_PRESENT) {
            // 屏幕解锁后重启心跳
            Log.i("保活 ScreenReceiver", "ACTION_USER_PRESENT")

        } else if (intent.action == Intent.ACTION_SCREEN_ON) {
            // 屏幕解锁后重启心跳
            Log.i("保活 ScreenReceiver", "ACTION_SCREEN_ON")
        } else if (intent.action == Intent.ACTION_SCREEN_OFF) {
            Log.i("保活 ScreenReceiver", "ACTION_SCREEN_OFF")
        }
    }
}